package ru.st.selenium.pages;
import static org.openqa.selenium.support.ui.ExpectedConditions.*;

import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.ui.Select;

public class MoviePage extends InternalPage {

	public MoviePage(PageManager pages) {
		super(pages);
	}
	
  @FindBy(css = "h2")
  private WebElement titleField;
	
  @FindBy(linkText = "Remove")
  private WebElement deleteButton;
  
  @FindBy(css = "nav a[href]")
  private WebElement homeLink;
  
  public MoviePage clickHomePage() {
	  homeLink.click();
	    return pages.moviePage;
	  }
  
   
  public String getTitle() {
    return titleField.getText();
  }

  
  public void clickDeleteButton() {
	  deleteButton.click();
	  }
  
  public MoviePage ensurePageLoaded() {
    super.ensurePageLoaded();
    wait.until(presenceOfElementLocated(By.cssSelector("div.content h2")));
    wait.until(presenceOfElementLocated(By.linkText("Remove")));
    return this;
  }
}

